package org.electrode.common;

import java.util.Enumeration;
import java.util.Vector;

public class CompoundSystem extends RobotSystem {
	private final Vector systems;
	private final String name;

	public CompoundSystem(String name) {
		this.name = name;
		this.systems = new Vector();
	}

	public void init() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).init();
		}
	}

	public void enableAuto() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).enableAuto();
		}
	}

	public void periodicAuto() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).periodicAuto();
		}
	}

	public void enableTeleop() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).enableTeleop();
		}
	}

	public void disable() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).disable();
		}
	}

	public void periodicTeleop() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).periodicTeleop();
		}
	}

	public void periodicTest() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).periodicTest();
		}
	}

	public String getName() {
		return name;
	}

	public void addSystem(RobotSystem system) {
		systems.addElement(system);
	}

	public void enableTest() {
		Enumeration stream = systems.elements();
		while (stream.hasMoreElements()) {
			((RobotSystem) stream.nextElement()).enableTest();
		}

	}
}
